WPF and Silverlight Edition Basic Library > Menu and ContextMenu > Menu and ContextMenu Elements > Adding Icons |
You can add an icon to a C1MenuItem in either XAML or Code
Complete the following steps:
XAML Copy Code <c1:C1MenuItem.Icon> <Image Source="YourImage.png" Height="12" Width="12" Margin="5,0,0,0"/> </c1:C1MenuItem.Icon>
Complete the following steps:
Visual Basic Copy Code Imports System.Windows.Media.Imaging
Example Title Copy Codeusing System.Windows.Media.Imaging;
Visual Basic Copy Code 'Create an image and assign it a source, margin, and width Dim ItemIcon As New Image() ItemIcon.Source = New BitmapImage(New Uri("02.png", UriKind.RelativeOrAbsolute)) ItemIcon.Margin = New Thickness(5, 0, 0, 0) ItemIcon.Height = 12 ItemIcon.Width = 12 'Set the C1MenuItem's icon property to the new image C1MenuItem.Icon = ItemIcon
C# Copy Code //Create an image and assign it a source, margin, and width Image ItemIcon = new Image(); ItemIcon.Source = new BitmapImage(new Uri("02.png", UriKind.RelativeOrAbsolute)); ItemIcon.Margin = new Thickness(5,0,0,0); ItemIcon.Height = 12; ItemIcon.Width = 12; //Set the C1MenuItem's icon property to the new image C1MenuItem1.Icon = ItemIcon;
The following image depicts a C1MenuItem with a 12x12 pixel icon.